<?php

namespace app\admin\controller;

use think\Request;
use think\Db;
use think\Controller;
use think\Log;
class Login extends Controller
{
	public function login()
	{
		return $this->fetch();
	}
	public function doLogin(User $user)
	{
			$user = $user->user_info($_POST);
			
			if($user['level']){
				if($user['username'] != $_POST['username']){
					echo json_encode(['status'=>0,'msg'=>'用户名不存在']);
					die();
				} elseif($user['password'] != $_POST['password']){
					echo json_encode(['status'=>0,'msg'=>'密码错误']);
					die();
				}elseif(!captcha_check($_POST['verify'])){
					echo json_encode(['status'=>0,'msg'=>'验证码错误']);
					die();
				} else {
					echo json_encode(['status'=>1,'msg'=>'登录成功']);
					die();
				}
				
				if(!captcha_check($_POST['verify'])){
					echo '验证失败';
				} else {
					echo '验证成功';
				}
			} else {
				echo json_encode(['status'=>0,'msg'=>'对不起,您不是管理员']);
				die();
			}

	}
}